package com.fg.pro.ai.controller;

import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import com.fg.pro.model.reponse.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ai图表mcp控制器
 *
 * @author Administrator
 * @date 2025/11/04
 */
@RestController
@RequestMapping("aiChartMcpController")
public class AiChartMcpController {

    @Autowired
    DashScopeChatModel dashScopeChatModel;

    @Operation(summary = "默认回答（拦截器自动加入JDBC记忆体-不同用户）",description = "")
    @GetMapping("/chartByAdviceAndMemoryAndUser")
    public ResponseResult chartByAdviceAndMemoryAndUser(@RequestParam(required = false)String question,
                                                        ToolCallbackProvider toolCallbackProvider) {
        ChatClient chatClient = ChatClient.builder(dashScopeChatModel)
                .defaultToolCallbacks(toolCallbackProvider).build();
        String content = chatClient
                .prompt()
                .user(question)
                .call()
                .content();
        return ResponseResult.okResult(content);
    }

    }
